// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"

#include <map>
#include <string>

HINSTANCE g_hInstance;

_glBlendColor glBlendColor;
_glBlendEquation glBlendEquation;
_glDrawRangeElements glDrawRangeElements;
_glColorTable glColorTable;
_glColorTableParameterfv glColorTableParameterfv;
_glColorTableParameteriv glColorTableParameteriv;
_glCopyColorTable glCopyColorTable;
_glGetColorTable glGetColorTable;
_glGetColorTableParameterfv glGetColorTableParameterfv;
_glGetColorTableParameteriv glGetColorTableParameteriv;
_glColorSubTable glColorSubTable;
_glCopyColorSubTable glCopyColorSubTable;
_glConvolutionFilter1D glConvolutionFilter1D;
_glConvolutionFilter2D glConvolutionFilter2D;
_glConvolutionParameterf glConvolutionParameterf;
_glConvolutionParameterfv glConvolutionParameterfv;
_glConvolutionParameteri glConvolutionParameteri;
_glConvolutionParameteriv glConvolutionParameteriv;
_glCopyConvolutionFilter1D glCopyConvolutionFilter1D;
_glCopyConvolutionFilter2D glCopyConvolutionFilter2D;
_glGetConvolutionFilter glGetConvolutionFilter;
_glGetConvolutionParameterfv glGetConvolutionParameterfv;
_glGetConvolutionParameteriv glGetConvolutionParameteriv;
_glGetSeparableFilter glGetSeparableFilter;
_glSeparableFilter2D glSeparableFilter2D;
_glGetHistogram glGetHistogram;
_glGetHistogramParameterfv glGetHistogramParameterfv;
_glGetHistogramParameteriv glGetHistogramParameteriv;
_glGetMinmax glGetMinmax;
_glGetMinmaxParameterfv glGetMinmaxParameterfv;
_glGetMinmaxParameteriv glGetMinmaxParameteriv;
_glHistogram glHistogram;
_glMinmax glMinmax;
_glResetHistogram glResetHistogram;
_glResetMinmax glResetMinmax;
_glTexImage3D glTexImage3D;
_glTexSubImage3D glTexSubImage3D;
_glCopyTexSubImage3D glCopyTexSubImage3D;
_glActiveTextureARB glActiveTextureARB;
_glClientActiveTextureARB glClientActiveTextureARB;
_glMultiTexCoord1dARB glMultiTexCoord1dARB;
_glMultiTexCoord1dvARB glMultiTexCoord1dvARB;
_glMultiTexCoord1fARB glMultiTexCoord1fARB;
_glMultiTexCoord1fvARB glMultiTexCoord1fvARB;
_glMultiTexCoord1iARB glMultiTexCoord1iARB;
_glMultiTexCoord1ivARB glMultiTexCoord1ivARB;
_glMultiTexCoord1sARB glMultiTexCoord1sARB;
_glMultiTexCoord1svARB glMultiTexCoord1svARB;
_glMultiTexCoord2dARB glMultiTexCoord2dARB;
_glMultiTexCoord2dvARB glMultiTexCoord2dvARB;
_glMultiTexCoord2fARB glMultiTexCoord2fARB;
_glMultiTexCoord2fvARB glMultiTexCoord2fvARB;
_glMultiTexCoord2iARB glMultiTexCoord2iARB;
_glMultiTexCoord2ivARB glMultiTexCoord2ivARB;
_glMultiTexCoord2sARB glMultiTexCoord2sARB;
_glMultiTexCoord2svARB glMultiTexCoord2svARB;
_glMultiTexCoord3dARB glMultiTexCoord3dARB;
_glMultiTexCoord3dvARB glMultiTexCoord3dvARB;
_glMultiTexCoord3fARB glMultiTexCoord3fARB;
_glMultiTexCoord3fvARB glMultiTexCoord3fvARB;
_glMultiTexCoord3iARB glMultiTexCoord3iARB;
_glMultiTexCoord3ivARB glMultiTexCoord3ivARB;
_glMultiTexCoord3sARB glMultiTexCoord3sARB;
_glMultiTexCoord3svARB glMultiTexCoord3svARB;
_glMultiTexCoord4dARB glMultiTexCoord4dARB;
_glMultiTexCoord4dvARB glMultiTexCoord4dvARB;
_glMultiTexCoord4fARB glMultiTexCoord4fARB;
_glMultiTexCoord4fvARB glMultiTexCoord4fvARB;
_glMultiTexCoord4iARB glMultiTexCoord4iARB;
_glMultiTexCoord4ivARB glMultiTexCoord4ivARB;
_glMultiTexCoord4sARB glMultiTexCoord4sARB;
_glMultiTexCoord4svARB glMultiTexCoord4svARB;
_glLoadTransposeMatrixfARB glLoadTransposeMatrixfARB;
_glLoadTransposeMatrixdARB glLoadTransposeMatrixdARB;
_glMultTransposeMatrixfARB glMultTransposeMatrixfARB;
_glMultTransposeMatrixdARB glMultTransposeMatrixdARB;
_glSampleCoverageARB glSampleCoverageARB;
_glSamplePassARB glSamplePassARB;
_glCompressedTexImage3DARB glCompressedTexImage3DARB;
_glCompressedTexImage2DARB glCompressedTexImage2DARB;
_glCompressedTexImage1DARB glCompressedTexImage1DARB;
_glCompressedTexSubImage3DARB glCompressedTexSubImage3DARB;
_glCompressedTexSubImage2DARB glCompressedTexSubImage2DARB;
_glCompressedTexSubImage1DARB glCompressedTexSubImage1DARB;
_glGetCompressedTexImageARB glGetCompressedTexImageARB;
_glColorTableEXT glColorTableEXT;
_glGetColorTableEXT glGetColorTableEXT;
_glGetColorTableParameterivEXT glGetColorTableParameterivEXT;
_glGetColorTableParameterfvEXT glGetColorTableParameterfvEXT;
_glLockArraysEXT glLockArraysEXT;
_glUnlockArraysEXT glUnlockArraysEXT;
_glSecondaryColor3bEXT glSecondaryColor3bEXT;
_glSecondaryColor3bvEXT glSecondaryColor3bvEXT;
_glSecondaryColor3dEXT glSecondaryColor3dEXT;
_glSecondaryColor3dvEXT glSecondaryColor3dvEXT;
_glSecondaryColor3fEXT glSecondaryColor3fEXT;
_glSecondaryColor3fvEXT glSecondaryColor3fvEXT;
_glSecondaryColor3iEXT glSecondaryColor3iEXT;
_glSecondaryColor3ivEXT glSecondaryColor3ivEXT;
_glSecondaryColor3sEXT glSecondaryColor3sEXT;
_glSecondaryColor3svEXT glSecondaryColor3svEXT;
_glSecondaryColor3ubEXT glSecondaryColor3ubEXT;
_glSecondaryColor3ubvEXT glSecondaryColor3ubvEXT;
_glSecondaryColor3uiEXT glSecondaryColor3uiEXT;
_glSecondaryColor3uivEXT glSecondaryColor3uivEXT;
_glSecondaryColor3usEXT glSecondaryColor3usEXT;
_glSecondaryColor3usvEXT glSecondaryColor3usvEXT;
_glSecondaryColorPointerEXT glSecondaryColorPointerEXT;

void InitGLFunc()
{
	glBlendColor = (_glBlendColor)wglGetProcAddress("glBlendColor");
	glBlendEquation = (_glBlendEquation)wglGetProcAddress("glBlendEquation");
	glDrawRangeElements = (_glDrawRangeElements)wglGetProcAddress("glDrawRangeElements");
	glColorTable = (_glColorTable)wglGetProcAddress("glColorTable");
	glColorTableParameterfv = (_glColorTableParameterfv)wglGetProcAddress("glColorTableParameterfv");
	glColorTableParameteriv = (_glColorTableParameteriv)wglGetProcAddress("glColorTableParameteriv");
	glCopyColorTable = (_glCopyColorTable)wglGetProcAddress("glCopyColorTable");
	glGetColorTable = (_glGetColorTable)wglGetProcAddress("glGetColorTable");
	glGetColorTableParameterfv = (_glGetColorTableParameterfv)wglGetProcAddress("glGetColorTableParameterfv");
	glGetColorTableParameteriv = (_glGetColorTableParameteriv)wglGetProcAddress("glGetColorTableParameteriv");
	glColorSubTable = (_glColorSubTable)wglGetProcAddress("glColorSubTable");
	glCopyColorSubTable = (_glCopyColorSubTable)wglGetProcAddress("glCopyColorSubTable");
	glConvolutionFilter1D = (_glConvolutionFilter1D)wglGetProcAddress("glConvolutionFilter1D");
	glConvolutionFilter2D = (_glConvolutionFilter2D)wglGetProcAddress("glConvolutionFilter2D");
	glConvolutionParameterf = (_glConvolutionParameterf)wglGetProcAddress("glConvolutionParameterf");
	glConvolutionParameterfv = (_glConvolutionParameterfv)wglGetProcAddress("glConvolutionParameterfv");
	glConvolutionParameteri = (_glConvolutionParameteri)wglGetProcAddress("glConvolutionParameteri");
	glConvolutionParameteriv = (_glConvolutionParameteriv)wglGetProcAddress("glConvolutionParameteriv");
	glCopyConvolutionFilter1D = (_glCopyConvolutionFilter1D)wglGetProcAddress("glCopyConvolutionFilter1D");
	glCopyConvolutionFilter2D = (_glCopyConvolutionFilter2D)wglGetProcAddress("glCopyConvolutionFilter2D");
	glGetConvolutionFilter = (_glGetConvolutionFilter)wglGetProcAddress("glGetConvolutionFilter");
	glGetConvolutionParameterfv = (_glGetConvolutionParameterfv)wglGetProcAddress("glGetConvolutionParameterfv");
	glGetConvolutionParameteriv = (_glGetConvolutionParameteriv)wglGetProcAddress("glGetConvolutionParameteriv");
	glGetSeparableFilter = (_glGetSeparableFilter)wglGetProcAddress("glGetSeparableFilter");
	glSeparableFilter2D = (_glSeparableFilter2D)wglGetProcAddress("glSeparableFilter2D");
	glGetHistogram = (_glGetHistogram)wglGetProcAddress("glGetHistogram");
	glGetHistogramParameterfv = (_glGetHistogramParameterfv)wglGetProcAddress("glGetHistogramParameterfv");
	glGetHistogramParameteriv = (_glGetHistogramParameteriv)wglGetProcAddress("glGetHistogramParameteriv");
	glGetMinmax = (_glGetMinmax)wglGetProcAddress("glGetMinmax");
	glGetMinmaxParameterfv = (_glGetMinmaxParameterfv)wglGetProcAddress("glGetMinmaxParameterfv");
	glGetMinmaxParameteriv = (_glGetMinmaxParameteriv)wglGetProcAddress("glGetMinmaxParameteriv");
	glHistogram = (_glHistogram)wglGetProcAddress("glHistogram");
	glMinmax = (_glMinmax)wglGetProcAddress("glMinmax");
	glResetHistogram = (_glResetHistogram)wglGetProcAddress("glResetHistogram");
	glResetMinmax = (_glResetMinmax)wglGetProcAddress("glResetMinmax");
	glTexImage3D = (_glTexImage3D)wglGetProcAddress("glTexImage3D");
	glTexSubImage3D = (_glTexSubImage3D)wglGetProcAddress("glTexSubImage3D");
	glCopyTexSubImage3D = (_glCopyTexSubImage3D)wglGetProcAddress("glCopyTexSubImage3D");
	glActiveTextureARB = (_glActiveTextureARB)wglGetProcAddress("glActiveTextureARB");
	glClientActiveTextureARB = (_glClientActiveTextureARB)wglGetProcAddress("glClientActiveTextureARB");
	glMultiTexCoord1dARB = (_glMultiTexCoord1dARB)wglGetProcAddress("glMultiTexCoord1dARB");
	glMultiTexCoord1dvARB = (_glMultiTexCoord1dvARB)wglGetProcAddress("glMultiTexCoord1dvARB");
	glMultiTexCoord1fARB = (_glMultiTexCoord1fARB)wglGetProcAddress("glMultiTexCoord1fARB");
	glMultiTexCoord1fvARB = (_glMultiTexCoord1fvARB)wglGetProcAddress("glMultiTexCoord1fvARB");
	glMultiTexCoord1iARB = (_glMultiTexCoord1iARB)wglGetProcAddress("glMultiTexCoord1iARB");
	glMultiTexCoord1ivARB = (_glMultiTexCoord1ivARB)wglGetProcAddress("glMultiTexCoord1ivARB");
	glMultiTexCoord1sARB = (_glMultiTexCoord1sARB)wglGetProcAddress("glMultiTexCoord1sARB");
	glMultiTexCoord1svARB = (_glMultiTexCoord1svARB)wglGetProcAddress("glMultiTexCoord1svARB");
	glMultiTexCoord2dARB = (_glMultiTexCoord2dARB)wglGetProcAddress("glMultiTexCoord2dARB");
	glMultiTexCoord2dvARB = (_glMultiTexCoord2dvARB)wglGetProcAddress("glMultiTexCoord2dvARB");
	glMultiTexCoord2fARB = (_glMultiTexCoord2fARB)wglGetProcAddress("glMultiTexCoord2fARB");
	glMultiTexCoord2fvARB = (_glMultiTexCoord2fvARB)wglGetProcAddress("glMultiTexCoord2fvARB");
	glMultiTexCoord2iARB = (_glMultiTexCoord2iARB)wglGetProcAddress("glMultiTexCoord2iARB");
	glMultiTexCoord2ivARB = (_glMultiTexCoord2ivARB)wglGetProcAddress("glMultiTexCoord2ivARB");
	glMultiTexCoord2sARB = (_glMultiTexCoord2sARB)wglGetProcAddress("glMultiTexCoord2sARB");
	glMultiTexCoord2svARB = (_glMultiTexCoord2svARB)wglGetProcAddress("glMultiTexCoord2svARB");
	glMultiTexCoord3dARB = (_glMultiTexCoord3dARB)wglGetProcAddress("glMultiTexCoord3dARB");
	glMultiTexCoord3dvARB = (_glMultiTexCoord3dvARB)wglGetProcAddress("glMultiTexCoord3dvARB");
	glMultiTexCoord3fARB = (_glMultiTexCoord3fARB)wglGetProcAddress("glMultiTexCoord3fARB");
	glMultiTexCoord3fvARB = (_glMultiTexCoord3fvARB)wglGetProcAddress("glMultiTexCoord3fvARB");
	glMultiTexCoord3iARB = (_glMultiTexCoord3iARB)wglGetProcAddress("glMultiTexCoord3iARB");
	glMultiTexCoord3ivARB = (_glMultiTexCoord3ivARB)wglGetProcAddress("glMultiTexCoord3ivARB");
	glMultiTexCoord3sARB = (_glMultiTexCoord3sARB)wglGetProcAddress("glMultiTexCoord3sARB");
	glMultiTexCoord3svARB = (_glMultiTexCoord3svARB)wglGetProcAddress("glMultiTexCoord3svARB");
	glMultiTexCoord4dARB = (_glMultiTexCoord4dARB)wglGetProcAddress("glMultiTexCoord4dARB");
	glMultiTexCoord4dvARB = (_glMultiTexCoord4dvARB)wglGetProcAddress("glMultiTexCoord4dvARB");
	glMultiTexCoord4fARB = (_glMultiTexCoord4fARB)wglGetProcAddress("glMultiTexCoord4fARB");
	glMultiTexCoord4fvARB = (_glMultiTexCoord4fvARB)wglGetProcAddress("glMultiTexCoord4fvARB");
	glMultiTexCoord4iARB = (_glMultiTexCoord4iARB)wglGetProcAddress("glMultiTexCoord4iARB");
	glMultiTexCoord4ivARB = (_glMultiTexCoord4ivARB)wglGetProcAddress("glMultiTexCoord4ivARB");
	glMultiTexCoord4sARB = (_glMultiTexCoord4sARB)wglGetProcAddress("glMultiTexCoord4sARB");
	glMultiTexCoord4svARB = (_glMultiTexCoord4svARB)wglGetProcAddress("glMultiTexCoord4svARB");
	glLoadTransposeMatrixfARB = (_glLoadTransposeMatrixfARB)wglGetProcAddress("glLoadTransposeMatrixfARB");
	glLoadTransposeMatrixdARB = (_glLoadTransposeMatrixdARB)wglGetProcAddress("glLoadTransposeMatrixdARB");
	glMultTransposeMatrixfARB = (_glMultTransposeMatrixfARB)wglGetProcAddress("glMultTransposeMatrixfARB");
	glMultTransposeMatrixdARB = (_glMultTransposeMatrixdARB)wglGetProcAddress("glMultTransposeMatrixdARB");
	glSampleCoverageARB = (_glSampleCoverageARB)wglGetProcAddress("glSampleCoverageARB");
	glSamplePassARB = (_glSamplePassARB)wglGetProcAddress("glSamplePassARB");
	glCompressedTexImage3DARB = (_glCompressedTexImage3DARB)wglGetProcAddress("glCompressedTexImage3DARB");
	glCompressedTexImage2DARB = (_glCompressedTexImage2DARB)wglGetProcAddress("glCompressedTexImage2DARB");
	glCompressedTexImage1DARB = (_glCompressedTexImage1DARB)wglGetProcAddress("glCompressedTexImage1DARB");
	glCompressedTexSubImage3DARB = (_glCompressedTexSubImage3DARB)wglGetProcAddress("glCompressedTexSubImage3DARB");
	glCompressedTexSubImage2DARB = (_glCompressedTexSubImage2DARB)wglGetProcAddress("glCompressedTexSubImage2DARB");
	glCompressedTexSubImage1DARB = (_glCompressedTexSubImage1DARB)wglGetProcAddress("glCompressedTexSubImage1DARB");
	glGetCompressedTexImageARB = (_glGetCompressedTexImageARB)wglGetProcAddress("glGetCompressedTexImageARB");
	glColorTableEXT = (_glColorTableEXT)wglGetProcAddress("glColorTableEXT");
	glGetColorTableEXT = (_glGetColorTableEXT)wglGetProcAddress("glGetColorTableEXT");
	glGetColorTableParameterivEXT = (_glGetColorTableParameterivEXT)wglGetProcAddress("glGetColorTableParameterivEXT");
	glGetColorTableParameterfvEXT = (_glGetColorTableParameterfvEXT)wglGetProcAddress("glGetColorTableParameterfvEXT");
	glLockArraysEXT = (_glLockArraysEXT)wglGetProcAddress("glLockArraysEXT");
	glUnlockArraysEXT = (_glUnlockArraysEXT)wglGetProcAddress("glUnlockArraysEXT");
	glSecondaryColor3bEXT = (_glSecondaryColor3bEXT)wglGetProcAddress("glSecondaryColor3bEXT");
	glSecondaryColor3bvEXT = (_glSecondaryColor3bvEXT)wglGetProcAddress("glSecondaryColor3bvEXT");
	glSecondaryColor3dEXT = (_glSecondaryColor3dEXT)wglGetProcAddress("glSecondaryColor3dEXT");
	glSecondaryColor3dvEXT = (_glSecondaryColor3dvEXT)wglGetProcAddress("glSecondaryColor3dvEXT");
	glSecondaryColor3fEXT = (_glSecondaryColor3fEXT)wglGetProcAddress("glSecondaryColor3fEXT");
	glSecondaryColor3fvEXT = (_glSecondaryColor3fvEXT)wglGetProcAddress("glSecondaryColor3fvEXT");
	glSecondaryColor3iEXT = (_glSecondaryColor3iEXT)wglGetProcAddress("glSecondaryColor3iEXT");
	glSecondaryColor3ivEXT = (_glSecondaryColor3ivEXT)wglGetProcAddress("glSecondaryColor3ivEXT");
	glSecondaryColor3sEXT = (_glSecondaryColor3sEXT)wglGetProcAddress("glSecondaryColor3sEXT");
	glSecondaryColor3svEXT = (_glSecondaryColor3svEXT)wglGetProcAddress("glSecondaryColor3svEXT");
	glSecondaryColor3ubEXT = (_glSecondaryColor3ubEXT)wglGetProcAddress("glSecondaryColor3ubEXT");
	glSecondaryColor3ubvEXT = (_glSecondaryColor3ubvEXT)wglGetProcAddress("glSecondaryColor3ubvEXT");
	glSecondaryColor3uiEXT = (_glSecondaryColor3uiEXT)wglGetProcAddress("glSecondaryColor3uiEXT");
	glSecondaryColor3uivEXT = (_glSecondaryColor3uivEXT)wglGetProcAddress("glSecondaryColor3uivEXT");
	glSecondaryColor3usEXT = (_glSecondaryColor3usEXT)wglGetProcAddress("glSecondaryColor3usEXT");
	glSecondaryColor3usvEXT = (_glSecondaryColor3usvEXT)wglGetProcAddress("glSecondaryColor3usvEXT");
	glSecondaryColorPointerEXT = (_glSecondaryColorPointerEXT)wglGetProcAddress("glSecondaryColorPointerEXT");
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
		g_hInstance=hModule;
		InitGLFunc();
		break;
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
	return TRUE;
}

BOOL g_bInit;
std::map<DWORD,std::string> g_glString;

extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
	if(g_bInit)
		return JNI_VERSION_1_2;
	
	WNDCLASS WndClass;
	WndClass.style=CS_OWNDC;
	WndClass.lpfnWndProc=DefWindowProc;
	WndClass.cbClsExtra = 0;
	WndClass.cbWndExtra = 0;
	WndClass.hInstance = g_hInstance;
	WndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
	WndClass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
	WndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
	WndClass.lpszMenuName = NULL;
	WndClass.lpszClassName = _T("win_tmp");

	if(RegisterClass(&WndClass)==0)
		return JNI_VERSION_1_2;

	HWND hWnd=CreateWindowEx(0,_T("win_tmp"),_T("a"),WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,CW_USEDEFAULT,CW_USEDEFAULT,10,10,NULL,NULL,g_hInstance,NULL);
	if(hWnd==NULL)
		return JNI_VERSION_1_2;
	
	HDC hdc=GetDC(hWnd);

	PIXELFORMATDESCRIPTOR ppfd={0};
	ppfd.iPixelType = PFD_TYPE_RGBA;
	ppfd.cColorBits = 16;
	ppfd.cDepthBits = 16;
	ppfd.nSize = sizeof(ppfd);
	ppfd.nVersion = 1;
	ppfd.dwFlags = PFD_SUPPORT_OPENGL|PFD_DRAW_TO_WINDOW|PFD_DOUBLEBUFFER;
	ppfd.iLayerType = 0;
	
	int pi=ChoosePixelFormat(hdc,&ppfd);
	if(pi==0)
	{
		ReleaseDC(hWnd,hdc);
		DestroyWindow(hWnd);
		return JNI_VERSION_1_2;
	}

	if(SetPixelFormat(hdc,pi,&ppfd)==FALSE)
	{
		ReleaseDC(hWnd,hdc);
		DestroyWindow(hWnd);
		return JNI_VERSION_1_2;
	}

	DescribePixelFormat(hdc,pi,sizeof(ppfd),&ppfd);
	HGLRC hglrc=wglCreateContext(hdc);
	wglMakeCurrent(hdc,hglrc);

	char* p= reinterpret_cast<char*>(const_cast<GLubyte*>(glGetString(GL_VERSION)));
	if(p)
		g_glString[GL_VERSION]=p;
	else
		g_glString[GL_VERSION]="NULL VER";

	p= reinterpret_cast<char*>(const_cast<GLubyte*>(glGetString(GL_EXTENSIONS)));
	if(p)
		g_glString[GL_EXTENSIONS]=p;
	else
		g_glString[GL_EXTENSIONS]="NULL EXT";

	p= reinterpret_cast<char*>(const_cast<GLubyte*>(glGetString(GL_VENDOR)));
	if(p)
		g_glString[GL_VENDOR]=p;
	else
		g_glString[GL_VENDOR]="NULL VENDOR";
	
	wglMakeCurrent(NULL,NULL);
	wglDeleteContext(hglrc);
	ReleaseDC(hWnd,hdc);
	DestroyWindow(hWnd);
	
	g_bInit=TRUE;
	return JNI_VERSION_1_2;
}

